﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sun
{
    public class DAL
    {
        public static List<Student> SelectAllStudent()
        {
            string sql = "select * from Student";
            using (SqlDataReader read = DBHerpel.MyDataReader(sql))
            {
                List<Student> list = new List<Student>();
                while (read.Read())
                {
                    Student stu = new Student();
                    stu.StuID = Convert.ToInt32(read["StuID"].ToString());
                    stu.StuName = read["StuName"].ToString();
                    //StuSex,StuAge,StuCity,Detail,StuDastr,StuOp
                    stu.StuSex = read["StuSex"].ToString();
                    stu.StuAge = int.Parse(read["StuAge"].ToString());
                    stu.StuCity = read["StuCity"].ToString();
                    stu.Detail = Convert.ToDecimal(read["Detail"].ToString());
                    stu.StuDastr = Convert.ToDateTime(read["StuDastr"].ToString());
                    stu.StuOp = read["StuOp"].ToString();

                    list.Add(stu);
                }
                return list;
            }
        }

    }
}
